<?php 
if (!isset($_SESSION)) {
  session_start();
}
$isPass = TRUE;
//echo isset($_POST['username']);
if (isset($_POST['username'])) {
	$username=$_POST['username'];
	$password=$_POST['password'];
	$MM_fldUserAuthorization = "";
	$MM_redirectLoginSuccess = "supplier_index.php"; //登入成功頁面
	//$MM_redirectLoginFailed = "admin_login.php"; //登入失敗頁面
	include_once '../../sys/com/model/db/CompanyMemberDAO.php';
	$companyMemberDAO = new CompanyMemberDAO();
	$companyMember = $companyMemberDAO->queryCompanyMember($username, $password);
	//echo "aaaaaaaaaaaaaaaaa".count($companyMember);
	if(count($companyMember)>0){ //若帳號密碼驗證成功
		//if (isset($_SESSION)) {
		//	session_destroy();
		//}
		//ob_start();
		//session_start();
		//ob_end_flush();
		$_SESSION["username"]=$username;
		$_SESSION["username"]=$password;
		$_SESSION["companyMember"]=$companyMember[0];
		header("Location: " . $MM_redirectLoginSuccess );
		exit;
	}else{
		$isPass = FALSE;
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>供應商登入</title>
<style type="text/css">
<!--
#index_up {
	width: 955px;
	background-image: url(../../images/top_bg.png);
	height: 82px;
}

.style1 {
	font-size: 14px;
	color: #666666;
	font-weight: bold;
}

.style2 {
	color: #666666;
	font-size: 12px;
}

.style3 {
	font-size: 13px;
	color: #FFFFFF;
}

.style8 {
	font-size: 7px;
	color: #FFFFFF;
}

#index_contant {
	width: 955px;
	margin-right: 33px;
	margin-left: 33px;
}

#index_body {
	width: 955px;
}

#index_body_1 {
	margin-top: 100px;
	margin-right: 200px;
	margin-bottom: 100px;
	margin-left: 200px;
	width: 555px;
}

#login_body {
	margin-right: 10px;
	margin-bottom: 10px;
	margin-left: 10px;
}

#login_body_up {
	background-image: url(../img/supplier_login_text.png);
	height: 25px;
	margin-bottom: 10px;
}
-->
</style>
<script src="../../admin/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
	function go(){
		if($("#username_id").val()==""){
			alert("請輸入帳號！");
			$("#username_id").focus();
			return false;
		}
		if($("#password_id").val()==""){
			alert("請輸入密碼！");
			$("#password_id").focus();
			return false;
		}
		$("#form1_id").submit();
	}
	
	<?php
		if(!$isPass){
	?>
	alert("帳號密碼驗證錯誤！");
	<?php
		}
	?>
</script>
</head>

<body>
<form id="form1_id" name="form1" method="post" action="supplier_login.php">
<table width="1024" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td>
		<div id="index_contant">
		<div id="index_up"></div>
		<div id="index_body">
		<div id="index_body_1">
		<table cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="3"><img src="../img/member_body_up.jpg" width="555" height="9" /></td>
			</tr>
			<tr>
				<td width="4" background="../img/member_body_left.jpg">&nbsp;</td>
				<td width="547">
				<div id="login_body_up"></div>
				<div id="login_body">
				<table width="527" cellpadding="10" cellspacing="0">
					<tr>
						<td width="165"><div align="right">帳號</div></td>
						<td colspan="2"><label> <input type="text" name="username" id="username_id" /> </label></td>
					</tr>
					<tr>
						<td><div align="right">密碼</div></td>
						<td colspan="2"><label> <input type="password" name="password" id="password_id" /> </label></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td width="157"><div align="right"><input type="button" name="button" id="button" value="登入" onclick="go();" /></div></td>
						<td width="143" class="style2">忘記密碼</td>
					</tr>
				</table>
				</div>
				</td>
				<td width="4" background="../img/member_body_right.jpg">&nbsp;</td>
			</tr>
			<tr>
				<td height="9" colspan="3"><img src="../img/member_body_down.jpg" width="555" height="9" /></td>
			</tr>
		</table>
		</div>
		</div>
		<div id="index_down">
		<?php include_once './template/footer.php'; //地 ?>
		</div>
		</div>
		</td>
	</tr>
</table>
<div align="center"></div>
</form>
</body>
</html>